<?php
if(!defined('ADMIN')){
	exit('Access Denied');
}

if($_POST['sub']!=''){

    $id=empty($_POST['id'])?0:(int)$_POST['id'];
	unset($_POST['id']);
	unset($_POST['sub']);
	$data=array('title'=>$_POST['title'],"posid"=>intval($_POST["posid"]),"starttime"=>trim($_POST["starttime"]),"endtime"=>trim($_POST["endtime"]),"disabled"=>intval($_POST["disabled"]),
    "thumb"=>trim($_POST["attachment_fileName"]),
    "description"=>trim($_POST["description"]),
    "url"=>trim($_POST["url"]),
    "create_time"=>time(),
    "uid"=>$_SESSION['EZ_Admin']['id'],    
    "username"=>$_SESSION['EZ_Admin']['name']
    );
    if(trim($_POST['title'])==""){
        jumpajax('300','焦点图名称不能为空','');
    }
    if(trim($_POST['url'])==""){
        jumpajax('300','焦点图链接地址不能为空','');
    } 
    if(trim($data['thumb'])==""){
        jumpajax('300','请选择本地图片上传，支持JPG、PNG、GIF格式','');
    }       
    
 	if($id==0){
	    $id=$ezhand->insert("focus",$data);
		jumpajax('200','保存成功','','closeCurrent');
	}
	else{
	    $ezhand->update("focus",$data,'id="'.$id.'"');
		jumpajax('200','修改成功','','closeCurrent');
	}
}
else{
	$id=empty($_GET['id'])?0:(int)$_GET['id'];
	$plist=$ezhand->select_all("focustype","id,title,picwidth,picheight");
    $poslist=array();
    while(list($k,$r)=each($plist)){
        
        $poslist[$r["id"]]=$r["title"]."[".$r["picwidth"]."*".$r["picheight"]."]";
    }
    
    
    if($id==0){
	    $row=array();
	}
	else{
	    $row=$ezhand->select("focus",'*','id="'.$id.'"');
	}
}
?>